#import "SproingeeView.h"

@implementation SproingeeView

- (id)initWithFrame:(NSRect)frameRect
{
    self = [super initWithFrame:frameRect];
    if (self) {
        _view = [[NSOpenGLView alloc] initWithFrame:frameRect];
        [self addSubview:_view];
    }

    return self;
}

- (NSTimeInterval)animationTimeInterval
{
    return 0.01;
}

- (void)setFrameSize:(NSSize)newSize
{
    [super setFrameSize:newSize];
    [_view setFrameSize:newSize];
    _initedGL = NO;

}

- (void)drawRect:(NSRect)rects
{
    
    [_view lockFocus];
    
    if (!_initedGL) {
        init_sproingies();
            reshape_sproingies((int)rects.size.width, (int)rects.size.height);

        _initedGL = YES;
    }

    [_view unlockFocus];
}


- (void)oneStep
{
    [_view lockFocus];

    draw_sproingies();
    [_view unlockFocus];

    
    return;
}


- (BOOL)hasConfigureSheet { return NO; }
- (NSWindow*)configureSheet { return nil; }

- (void)closeSheet:(id)sender
{
    [NSApp endSheet:nil];
}

@end
